package voronin;

import java.io.IOException;
import java.net.Socket;

public class SocketSource implements ConnectionSource<Socket> {
    private final String host;
    private final int port;

    public SocketSource(String host, int port) {
        this.port = port;
        this.host = host;
    }

    @Override
    public Socket open() {
        try {
            return new Socket(host, port);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void close(Socket obj) {
        try {
            obj.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
